/**
 * 
 */
package com.action;

import java.io.PrintWriter;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.cms.manager.CmsManager;


/**
 * @author jun.huang
 * 
 */
public class IAction extends DefaultAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Logger logger = Logger.getLogger(this.getClass());
	private String spid;
	private String toicp;
	private String code;
	public String execute() {
		return null;
	}
	
	public IAction() {
	}
	public String get()
	{
		String responseStr = CmsManager.getInstance().getCms(spid, toicp, code);
		logger.info("getcms request[spid:"+spid+
				" toicp:"+toicp+" code:"+code+"] response["+responseStr+"]");
		return out(responseStr);
	}
	
	private String out(String rsp)
	{
		try {
			//rsp = Base64.encode(rsp.getBytes("UTF-8"));
			setContentLength(rsp.getBytes("utf-8").length);
			setContentType("text/plain;charset=utf-8");
			PrintWriter pw = getResponse().getWriter();
			pw.write(rsp);
			pw.flush();
			pw.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		//logger.info("response base64: " + rsp);
		return null;
	}

	public String getSpid() {
		return spid;
	}

	public void setSpid(String spid) {
		this.spid = spid;
	}

	public String getToicp() {
		return toicp;
	}

	public void setToicp(String toicp) {
		this.toicp = toicp;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
		
}
